<template>
	<view>
		<u-popup v-model="show" mode="center" border-radius="16" width="600rpx" height="600rpx">
			<view class="confirm_box">
				<view class="title" v-if="params.packages_id">请设置您得到的推广奖励</view>
				<view class="title" v-else>批量设置您得到的推广奖励</view>
				<!-- <view class="text" v-show="rebate">
					<text>
						我的佣金 {{rebate}}
					</text>
				</view> -->
				<view class="sub-title">您下级的佣金为您当前佣金减去您设置的推广奖励</view>
				
				<view style="flex: 1;">
					<view class="text" v-show="this.nickname">
						<text>
							代理名称 {{nickname}}
						</text>
					</view>
					<view class="text" style="padding:40rpx 30rpx;">
						<!-- <view class="max-money">您当前的佣金为{{rebate}}元</view> -->
						<u-input style="margin-bottom: 20rpx;" v-model="params.money" type="text" :clearable='false' :placeholder="'请输入您得到的推广报酬，≤元改为建议5元'" border/>
						<!-- <u-input v-if="params.packages_id" v-model="dayName" :clearable='false' placeholder='请输入结算周期' border readonly @click="showPicker" /> -->
					</view>
				</view>
				
				<!-- <scroll-view :scroll-y="true" class="gy-center goods-tz-content">
					<u-parse :html="configData.xiaji_yongjin_content"></u-parse>
				</scroll-view> -->
				
				<view class="btn">
					<text class="btn_left" @click="show=false">取消</text>
					<text class="btn_right" @click="defineBtn">确定</text>
				</view>
			</view>
		</u-popup>
		
		<u-picker v-model="zqShow" mode="selector" :range="zqRange" range-key="name" @confirm="confirmZq" confirm-color="#26C281"></u-picker>
	</view>
</template>

<script>
	export default {
		name:"confirm_receipt",
		data() {
			return {
				maxMoney: 20,
				show:false,
				id:'',
				money:'',
				packages_id:'',
				nickname:'',
				agent_id:'',
				type:'',
				rebate:'',
				params:{},
				dayName: '',
				zqShow: false,
				zqRange: [
					// 当日，次日，第三日，第四日，第五日，次月30日
					// {id: 1, name: '当日'},
					// {id: 2, name: '次日'},
					// {id: 3, name: '第三日'},
					// {id: 4, name: '第四日'},
					// {id: 5, name: '第五日'},
					// {id: 6, name: '次月30日'},
				],
				configData: {}
			};
		},
		// created(){
		// 	this.peizhi();
		// },
		methods:{
			showPicker() {
				this.zqShow = true
			},
			peizhi(packages_id,agent_id){
				
			},
			confirmZq(e) {
				const obj = this.zqRange[e[0]]
				this.params.day = obj.id
				this.dayName = obj.name
			},
			openBtn(val,agent_id,rebate){
				
				this.params.packages_id  = val
				this.params.agent_id     = agent_id
				this.rebate              = rebate
				this.show=true
				// this.zqRange             = zqRange
				this.dayName = ''
				this.params.day = ''
				this.params.money = ''
				
				var send = {
					packages_id:val,
					agent_id:agent_id,
					}
				this.$httpApi.zqRange(send).then((res)=>{
					this.zqRange = res.data;
				})
				
				// this.$httpApi.indexConfig().then(res => {
				// 	this.configData = res.data
				// })
				
			},
			openBtnTwo(val){
				this.params.agent_id    = val
				this.params.type        = 'unify_commission'
				this.show=true
				this.zqRange             = zqRange
				
				this.$httpApi.zqRange(send).then((res)=>{
					this.zqRange = res.data;
				})
				
				// this.$httpApi.indexConfig().then(res => {
				// 	this.configData = res.data
				// })
			},
			openBtnThree(val,nickname){
				this.params.packages_id  = ''
				this.params.agent_id    = val
				this.nickname           = nickname
				this.params.type         = 'spread'
				this.show=true
				
				this.$httpApi.zqRange({}).then((res)=>{
					this.zqRange = res.data;
				})
				this.$httpApi.indexConfig().then(res => {
					this.configData = res.data
				})
			},
			receiptFour(val){
				this.params.packages_id    = val;
				this.show=true
			},
			closeBtn(){
				this.show=false
			},
			defineBtn(){
				var that = this
				that.$tips.showLoading('确认中')
				if(that.params.agent_id){
					that.$httpApi.addconfig(that.params).then((res)=>{
						that.$tips.hideLoading()
						if(res.code==1){
							this.id=''
							this.show=false
							this.$emit('submit')
						}
					})
				}else{
					// that.$httpApi.batchconfig(that.params).then((res)=>{
					that.$httpApi.team_all_money(that.params).then((res)=>{
						that.$tips.hideLoading()
						if(res.code==1){
							this.id=''
							this.show=false
							this.$emit('submit')
						}
					})
				}
				
			},
		}
	}
</script>

<style lang="less">
	.max-money {
		text-align: left;
		font-weight: 400;
		font-size: 28rpx;
		margin-bottom: 20rpx;
	}
	.goods-tz-content {
		width: fit-content;
		padding: 0 30rpx;
		height: 400rpx;
	}
	.confirm_box{
		width: 100%;
		height: 100%;
		padding: 40rpx 0;
		background: red;
		background: linear-gradient(to bottom, rgba(38, 194, 129, 0.20), rgba(38, 194, 129, 0), rgba(38, 194, 129, 0));
		display: flex;
		// justify-content: space-between;
		flex-direction: column;
		.title{
			width: 100%;
			font-size: 36rpx;
			text-align: center;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #222222;
		}
		.sub-title {
			font-size: 26rpx;
			font-weight: 400;
			text-align: center;
		}
		.text{
			width: 100%;
			text-align: center;
			font-size: 32rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #666666;
		}
		.btn{
			width: 100%;
			padding: 0 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-around;
			text{
				display: block;
				width: 247rpx;
				height: 80rpx;
				text-align: center;
				font-size: 32rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				border-radius: 40rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			.btn_left{
				color: #999;
				border: 1px solid #999999;
			}
			.btn_right{
				color: #fff;
				background: #26C281;
			}
		}
	}
</style>